package demo06Exception;

import projectdemo01.user.User;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:咭咭熊
 * Date:2021 - 09 - 27
 * Time:15:57
 */

//1.自定义处理用户名错误的异常
class UserException extends  RuntimeException{
    public UserException(String message) {
        super(message);
    }
}
//2.自定义处理密码错误的异常
class PasswordException extends  RuntimeException{
    public PasswordException(String message) {
        super(message);
    }
}
public class TestDemo03 {
    public static String Username = "admin";
    public static String Password = "admin";

    public static void main(String[] args) {
        if(!TestDemo03.Username.equals(Username)){
            throw new UserException("用户名错误");
        }
        if(!TestDemo03.Password.equals(Password)){
            throw new PasswordException("密码错误");
        }
        System.out.println("登陆成功");
    }
}
